<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>唯爱薇o朝圣之路-课程</title>
    <script src="https://unpkg.com/vue@next"></script>
</head>
<body>
    <h1>唯爱薇o朝圣之路-添加课程实验</h1>
    <hr/>
    <div id="app">
        <!-- 演示for循环显示课程 -->
        <!-- Vue.createApp(
            {
                data() {
    
                    return {
                        courses: ['DevOps课程','Network Arch课程', 'NodeJS课程', 'VUE3课程']
                    }
                    
                },
                template: `<div>
                    <ul>
                        <li v-for="(course,index) of courses"> [{{ index }}] -- {{ course }} </li>
                    </ul>
                </div>`,
            }
        ).mount("#app") -->



    </div>
    
</body>
<script>
    Vue.createApp(
        {
            data() {

                return {
                    //---此处添加变量名称
                    courseName:'',
                    courses: []
                }
                
            },
            methods: {
                addCourse() {
                    this.courses.push(this.courseName)
                    this.courseName=""
                }
            },
            template: `<div>
                <input v-model="courseName" />
                <hr />
                <button v-on:click="addCourse">添加课程</button>
                <hr />
                
                <ul>
                    <li v-for="(course,index) of courses"> [{{ index }}] -- {{ course }} </li>
                </ul>
            </div>`,
        }
    ).mount("#app")
</script>
</html>